<template>
  <el-dialog
    class="eldialog el-dialog-m0"
    :visible.sync="visible"
    :title="title"
    :close-on-click-modal="false"
    append-to-body
    top="2vh"
    width="100%"
    :close-on-press-escape="false"
    element-loading-text="数据加载中"
    v-loading="loading"
  >
    <el-form
      :inline="true"
      :model="msgData"
      :rules="rules"
      ref="msgData"
      class="demo-form-inline"
    >
      <el-row>
        <el-col :span="24" align="center">
          <el-form-item prop="dw">
            <el-input
              :disabled="flag"
              maxlength="30"
              size="small"
              placeholder="请输入单位名称"
              v-model="msgData.dw"
            >
            </el-input>
          </el-form-item>
          <span
            style="
              font-size: 28px;
              line-height: 32px;
              font-weight: 900;
              height: 50px;
            "
            >省直部门单位2024年度年轻干部配备提升计划表</span
          >
          <el-button
            style="margin-right: 30px; margin-top: 10px; float: right"
            type="primary"
            plain
            @click="downZip"
            >&nbsp;导出<i class="el-icon-upload el-icon--right"></i>
          </el-button>

          <el-button
            v-if="btType === '2'"
            style="margin-right: 10px; margin-top: 10px; float: right"
            type="primary"
            icon="el-icon-edit"
            plain
            @click="auditTable()"
            :disabled="shztBegin === '1' || shztGHB === '1'"
            >&nbsp;审核
          </el-button>
          <el-button
            v-if="btType === '2' && (shztBegin === '1' || shztGHB === '1')"
            style="margin-right: 10px; margin-top: 10px; float: right"
            type="primary"
            icon="el-icon-edit"
            plain
            @click="
              flag = false;
              shztBegin = '0';
              shztGHB = '0';
            "
            >&nbsp;修改
          </el-button>
          <el-button
            v-if="role == '系统管理员'"
            style="margin-right: 10px; margin-top: 10px; float: right"
            type="primary"
            icon="el-icon-edit"
            plain
            @click="save('msgData')"
            >&nbsp;保存
          </el-button>
          <el-button
            v-else
            style="margin-right: 10px; margin-top: 10px; float: right"
            type="primary"
            icon="el-icon-edit"
            plain
            @click="save('msgData')"
            :disabled="flag"
            >&nbsp;保存
          </el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-form-item label="填表人：" prop="tbr">
          <el-input
            :disabled="flag"
            maxlength="15"
            size="small"
            placeholder="请输入填表人姓名"
            v-model="msgData.tbr"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="联系方式：" prop="lxfs">
          <el-input
            :disabled="flag"
            size="small"
            placeholder="请输入联系方式"
            oninput="if(value.length>15)value=value.slice(0,15)"
            v-model="msgData.lxfs"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="表格盖章扫描:">
          <div v-if="excelData.excelFile == ''">
            <el-upload
              style="margin-bottom: 5px"
              class="upload-demo"
              accept=".pdf"
              :action="fileServerPath"
              :show-file-list="false"
              :on-success="
                (response, file, fileList) =>
                  excelFileUpload(response, file, fileList)
              "
              :before-upload="beforeAvatarUpload"
              :multiple="false"
              :disabled="flag"
            >
              <el-button :disabled="flag" size="small" type="primary">
                上传<i class="el-icon-upload el-icon--right"></i>
              </el-button>
            </el-upload>
          </div>
          <div v-else-if="excelData.excelFile != '' && flag == true">
            <el-link type="primary" @click="showFile(excelData.excelFile)">
              {{ excelData.excelFileName }}
            </el-link>
          </div>
          <div v-else>
            <el-upload
              style="margin-bottom: 5px"
              class="upload-demo"
              accept=".pdf"
              :action="fileServerPath"
              :show-file-list="false"
              :on-success="
                (response, file, fileList) =>
                  excelFileUpload(response, file, fileList)
              "
              :before-upload="beforeAvatarUpload"
              :multiple="false"
              :disabled="flag"
            >
              <a>{{ excelData.excelFileName }}</a>
            </el-upload>
          </div>
        </el-form-item>
      </el-row>
    </el-form>
    <!-- 第一个表格 -->
    <el-row>
      <el-col>
        <table class="myTable">
          <thead>
            <tr>
              <td colspan="17">中层正职(正处级领导职务)</td>
            </tr>
            <tr>
              <td style="width: 400px" colspan="3" rowspan="3">人员构成</td>
              <td colspan="4">2023年底配备情况</td>
              <td colspan="3">2023年调整情况</td>
              <td colspan="2">储备情况</td>
              <td colspan="5">2024年配备目标</td>
            </tr>
            <tr>
              <td rowspan="2">批复职数</td>
              <td rowspan="2">2023年底实配数量</td>
              <td rowspan="2">中层正职平均年龄(岁)</td>
              <td rowspan="2">"82后"中层正职干部人数</td>
              <td rowspan="2">2023年内新选拔中层正职人数</td>
              <td class="borderNone" colspan="2">&nbsp;</td>
              <td rowspan="2">2024年内符合提拔为中层正职干部人数</td>
              <td class="borderNone" colspan="1">&nbsp;</td>
              <td rowspan="2">2024年内预计可调整岗位数量</td>
              <td rowspan="2">2024年内计划补充中层正职干部人数</td>
              <td class="borderNone" colspan="2">&nbsp;</td>
              <td rowspan="2">2024年底"83后"中层正职干部人数计划达到</td>
            </tr>
            <tr>
              <td>其中"82后"干部人数</td>
              <td>占比</td>
              <td>其中"83后"干部人数</td>
              <td>其中"83后"干部人数</td>
              <td>占比</td>
            </tr>
          </thead>
          <tbody>
            <template v-for="(item, index) in pbtsjhData">
              <tr :key="index">
                <td colspan="3" v-if="item.rygc == '1'">
                  <p>全部人员</p>
                  <p>（机关+参公+事业）</p>
                </td>
                <td colspan="3" v-if="item.rygc != '1'">
                  <p>公务员</p>
                  <p>（机关+参公）</p>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzZsgwPfzs = $event.target.value"
                    v-model="item.zczzZsgwPfzs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzZsgwPbsl = $event.target.value"
                    v-model="item.zczzZsgwPbsl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbqkPjnl = $event.target.value"
                    v-model="item.zczzPbqkPjnl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*/g, '$1')"
                    @blur="item.zczzZsgwGbrs82 = $event.target.value"
                    v-model="item.zczzZsgwGbrs82"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbqkXxb = $event.target.value"
                    v-model="item.zczzPbqkXxb"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                  :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbqkGbrs82 = $event.target.value"
                    v-model="item.zczzPbqkGbrs82"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="item.zczzPbqkZb"> </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzCbqkFhtbrs = $event.target.value"
                    v-model="item.zczzCbqkFhtbrs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzCbqk83rs = $event.target.value"
                    v-model="item.zczzCbqk83rs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbmbKtzrs = $event.target.value"
                    v-model="item.zczzPbmbKtzrs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbmbJhbc = $event.target.value"
                    v-model="item.zczzPbmbJhbc"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                  :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbmb83rs = $event.target.value"
                    v-model="item.zczzPbmb83rs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="item.zczzPbmbZb"> </el-input>
                </td>
                <!-- 干部人数计划达到 -->
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zczzPbmbJhdd83 = $event.target.value"
                    v-model="item.zczzPbmbJhdd83"
                  >
                  </el-input>
                </td>
              </tr>
            </template>
          </tbody>
        </table>
      </el-col>
    </el-row>
    <!-- 第二个表格 -->
    <el-row>
      <el-col>
        <table class="myTable">
          <thead>
            <tr>
              <td colspan="17">中层副职(副处级领导职务)</td>
            </tr>
            <tr>
              <td style="width: 400px" colspan="3" rowspan="3">人员构成</td>
              <td colspan="4">2023年底配备情况</td>
              <td colspan="3">2023年调整情况</td>
              <td colspan="2">储备情况</td>
              <td colspan="5">2024年配备目标</td>
            </tr>
            <tr>
              <td rowspan="3">批复职数</td>
              <td rowspan="2">2023年底实配数量</td>
              <td rowspan="2">中层副职平均年龄(岁)</td>
              <td rowspan="2">"87后"中层副职干部人数</td>
              <td rowspan="2">2023年内新选拔中层副职人数</td>
              <td class="borderNone" colspan="2">&nbsp;</td>
              <td rowspan="2">2024年内符合提拔为中层副职干部人数</td>
              <td class="borderNone" colspan="1">&nbsp;</td>
              <td rowspan="2">2024年内预计可调整岗位数量</td>
              <td rowspan="2">2024年内计划补充中层副职干部人数</td>
              <td class="borderNone" colspan="2">&nbsp;</td>
              <td rowspan="2">2024年底"88后"中层副职干部人数计划达到</td>
            </tr>
            <tr>
              <td>其中"87后"干部人数</td>
              <td>占比</td>
              <td>其中"88后"干部人数</td>
              <td>其中"88后"干部人数</td>
              <td>占比</td>
            </tr>
          </thead>
          <tbody>
            <template v-for="(item, index) in pbtsjhData">
              <tr :key="index">
                <td colspan="3" v-if="item.rygc == '1'">
                  <p>全部人员</p>
                  <p>（机关+参公+事业）</p>
                </td>
                <td colspan="3" v-if="item.rygc != '1'">
                  <p>公务员</p>
                  <p>（机关+参公）</p>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzZsgwPfzs = $event.target.value"
                    v-model="item.zcfzZsgwPfzs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzZsgwPbsl = $event.target.value"
                    v-model="item.zcfzZsgwPbsl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbqkPjnl = $event.target.value"
                    v-model="item.zcfzPbqkPjnl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*/g, '$1')"
                    @blur="item.zcfzZsgwGbrs87 = $event.target.value"
                    v-model="item.zcfzZsgwGbrs87"
                  >
                  </el-input>
                </td>
                <!-- 中层副职人数 -->
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbqkGbrs87 = $event.target.value"
                    v-model="item.zcfzPbqkGbrs87"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                  :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbqk87gbrs = $event.target.value"
                    v-model="item.zcfzPbqk87gbrs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="item.zcfzPbqkZb"> </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzCbqkFhtbsl = $event.target.value"
                    v-model="item.zcfzCbqkFhtbsl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzCbqk88rs = $event.target.value"
                    v-model="item.zcfzCbqk88rs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbmbKtzrs = $event.target.value"
                    v-model="item.zcfzPbmbKtzrs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbmbJhbc = $event.target.value"
                    v-model="item.zcfzPbmbJhbc"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbmb88rs = $event.target.value"
                    v-model="item.zcfzPbmb88rs"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="item.zcfzPbmbZb"> </el-input>
                </td>
                <td>
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="item.zcfzPbmbJhdd88 = $event.target.value"
                    v-model="item.zcfzPbmbJhdd88"
                  >
                  </el-input>
                </td>
              </tr>
            </template>
          </tbody>
        </table>
      </el-col>
    </el-row>
    <!-- 第三个表格 -->
    <el-row>
      <el-col>
        <table class="myTable">
          <thead>
            <tr>
              <td colspan="17">内设机构和下属单位（监测指标）</td>
            </tr>
            <tr>
              <td colspan="10">2023年底配备情况</td>
              <td colspan="7">2024年配备目标</td>
            </tr>
            <tr>
              <td colspan="4">2023年底内设机构和下属单位数量</td>
              <td colspan="5">
                配备"82后"中层正职或"87后"中层副职的内设机构和下属单位数量
              </td>
              <td>占比</td>
              <td colspan="2">截至目前内设机构和下属单位数量</td>
              <td colspan="4">
                配有"83后"中层正职或"88后"中层副职的内设机构和下属单位数量计划达到
              </td>
              <td>占比</td>
            </tr>
          </thead>
          <tbody>
            <template v-for="(itemJczb, index) in listJczb">
              <tr :key="index">
                <td colspan="4">
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="itemJczb.pbqkSl = $event.target.value"
                    v-model="itemJczb.pbqkSl"
                  >
                  </el-input>
                </td>
                <td colspan="5">
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="itemJczb.pbqk82or87sl = $event.target.value"
                    v-model="itemJczb.pbqk82or87sl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="itemJczb.pbqkZb"> </el-input>
                </td>
                <td colspan="2">
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="itemJczb.pbmbSl = $event.target.value"
                    v-model="itemJczb.pbmbSl"
                  >
                  </el-input>
                </td>
                <td colspan="4">
                  <el-input
                    :disabled="flag"
                    onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                    @blur="itemJczb.pbmb83or88sl = $event.target.value"
                    v-model="itemJczb.pbmb83or88sl"
                  >
                  </el-input>
                </td>
                <td>
                  <el-input disabled v-model="itemJczb.pbmbZb"> </el-input>
                </td>
              </tr>
            </template>
          </tbody>
        </table>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <p>说明：</p>
        <p>
          1.配备指标要求根据即将制定印发的《关于贯彻<全国党政领导班子建设规划纲要(2024一2028年)>的实施意见》确定。
        </p>
        <p>2.相应层次年轻干部占比，保留小数点后1位。</p>
        <p>3.今年1月至今，已进行干部调整的，也应纳入年度配备提升计划统计。</p>
        <p>
          4.此表请通过年轻干部工作督导评估系统进行线上填报，并上传盖章扫描版。
        </p>
      </el-col>
    </el-row>
    <el-row>
      <vxe-table style="width: 100%" :data="tsqksmData" border>
        <vxe-column align="center" title="特殊情况说明">
          <!-- style="text-align: right;"-->
          <template slot-scope="scope">
            <el-input
              :disabled="flag"
              maxlength="300"
              placeholder="请输入特殊情况说明"
              v-if="scope.row.type == 1"
              v-model="scope.row.tsqk"
              type="textarea"
              :rows="3"
              :autosize="{ minRows: 3, maxRows: 6 }"
            >
            </el-input>
            <span v-if="scope.row.type == '2'">
              <div>
                附件：
                <div
                  v-for="(item, i) in scope.row.tsqkFileName"
                  style="margin-bottom: 5px"
                >
                  <el-link
                    type="primary"
                    @click="showFile(scope.row.tsqkFile[i])"
                  >
                    {{ i + 1 }} 、 {{ item }}
                  </el-link>
                  <el-button
                    :disabled="flag"
                    style="margin-left: 20px"
                    type="danger"
                    icon="el-icon-delete"
                    circle
                    size="mini"
                    @click="delFileByTsqk(i)"
                  >
                  </el-button>
                </div>
              </div>
              <el-upload
                style="margin-bottom: 5px"
                class="upload-demo"
                accept=".pdf"
                :action="fileServerPath"
                :show-file-list="false"
                :on-success="
                  (response, file, fileList) =>
                    fileUpload(response, file, fileList)
                "
                :before-upload="beforeAvatarUpload"
                :multiple="false"
                :disabled="flag"
              >
                <el-button :disabled="flag" size="small" type="primary">
                  特殊情况附件<i class="el-icon-upload el-icon--right"></i>
                </el-button>
              </el-upload>
            </span>
          </template>
        </vxe-column>
      </vxe-table>
    </el-row>
    <archiveFile-show ref="dialogarchiveFile" />
  </el-dialog>
</template>
    
<script>
/*方法引用*/
import store from "@/store";
import {
  getList2024,
  save2024,
  downLsqk2024,
  auditTable,
} from "@/api/young/evaluation/infoFilling/infoFilling.js";
import webapp from "@/config/webapp";
import archiveFileShow from "@/views/young/evaluation/archiveFile";

export default {
  name: "pbtsjhTable2023_sz",
  components: { "archiveFile-show": archiveFileShow },
  data() {
    return {
      title: "配备提升计划表",
      visible: false,
      disabled: true,

      loading: false,
      flag: false,
      role: "",
      btType: "",
      shztBegin: "",
      shztGHB: "",
      task: {},
      pbtsjhData: [],
      listJczb:[],
      tsqksmData: [
        /* {
            "tsqk" : "",
            "type" : "1"
          },
          {
            "tsqkFile" : [],
            "tsqkFileName" : [],
            "type" : "2"
          }*/
      ], //特殊情况说明数据
      msgData: {
        id: "",
        dw: "",
        tbr: "",
        lxfs: "",
        taskId: "",
        sjd: "",
      },
      excelData: {
        excelFile: "",
        excelFileName: "",
      },
      options: [
        {
          value: "1",
          label: "上升",
        },
        {
          value: "0",
          label: "持平",
        },
        {
          value: "-1",
          label: "下降",
        },
      ],
      taskId: "",
      fileServerPath: webapp.GHB_URL + "/evaluation/excel/fileUpload",
      rules: {
        tbr: [{ required: true, message: "请输入填表人姓名", trigger: "blur" }],
        lxfs: [{ required: true, message: "请输入联系方式", trigger: "blur" }],
        dw: [{ required: true, message: "请输入单位名称", trigger: "blur" }],
      },
      reg: /^([1-9][0-9]*|0)(\.[0-9]*[1-9])?$/,
    };
  },
  watch: {
    pbtsjhData: {
      handler: function () {
        this.pbtsjhData.forEach((item) => {
          //中层正职-2023年调整情况占比
          if (
            item.zczzPbqkXxb != "" &&
            item.zczzPbqkXxb != null &&
            this.reg.test(item.zczzPbqkGbrs82) &&
            this.reg.test(item.zczzPbqkXxb) &&
            item.zczzPbqkGbrs82 != "" &&
            item.zczzPbqkGbrs82 != null &&
            item.zczzPbqkXxb != 0
          ) {
            item.zczzPbqkZb =
              ((item.zczzPbqkGbrs82 / item.zczzPbqkXxb) * 100).toFixed(2) + "%";
          } else {
            if (!item.zczzPbqkZb) {
              item.zczzPbqkZb = "0.0%";
            }
          }
          //中层正职-2024年配备目标占比
          if (
            item.zczzPbmbJhbc != "" &&
            item.zczzPbmbJhbc != null &&
            this.reg.test(item.zczzPbmb83rs) &&
            this.reg.test(item.zczzPbmbJhbc) &&
            item.zczzPbmb83rs != "" &&
            item.zczzPbmb83rs != null &&
            item.zczzPbmbJhbc != 0
          ) {
            item.zczzPbmbZb =
              ((item.zczzPbmb83rs / item.zczzPbmbJhbc) * 100).toFixed(2) + "%";
          } else {
            if (!item.zczzPbmbZb) {
              item.zczzPbmbZb = "0.0%";
            }
          }
          //中层副职-2023年调整情况占比
          if (
            item.zcfzPbqkGbrs87 != "" &&
            item.zcfzPbqkGbrs87 != null &&
            this.reg.test(item.zcfzPbqkGbrs87) &&
            this.reg.test(item.zcfzPbqk87gbrs) &&
            item.zcfzPbqk87gbrs != "" &&
            item.zcfzPbqk87gbrs != null &&
            item.zcfzPbqkGbrs87 != 0
          ) {
            item.zcfzPbqkZb =
              ((item.zcfzPbqk87gbrs / item.zcfzPbqkGbrs87) * 100).toFixed(2) +
              "%";
          } else {
            if (!item.zcfzPbqkZb) {
              item.zcfzPbqkZb = "0.0%";
            }
          }
          //中层副职-2024年配备目标占比
          if (
            item.zcfzPbmbJhbc != "" &&
            item.zcfzPbmbJhbc != null &&
            this.reg.test(item.zcfzPbmbJhbc) &&
            this.reg.test(item.zcfzPbmb88rs) &&
            item.zcfzPbmb88rs != "" &&
            item.zcfzPbmb88rs != null &&
            item.zcfzPbmbJhbc != 0
          ) {
            item.zcfzPbmbZb =
              ((item.zcfzPbmb88rs / item.zcfzPbmbJhbc) * 100).toFixed(2) + "%";
          } else {
            if (!item.zcfzPbmbZb) {
              item.zcfzPbmbZb = "0.0%";
            }
          }
        });
      },
      deep: true,
    },
    listJczb:{
      handler: function () {
        this.listJczb.forEach((itemJczb) => {
          // 监测指标2023年底配备情况
          if (
            itemJczb.pbqkSl != "" &&
            itemJczb.pbqkSl != null &&
            this.reg.test(itemJczb.pbqkSl) &&
            this.reg.test(itemJczb.pbqk82or87sl) &&
            itemJczb.pbqk82or87sl != "" &&
            itemJczb.pbqk82or87sl != null &&
            itemJczb.pbqkSl != 0
          ) {
            itemJczb.pbqkZb =
              ((itemJczb.pbqk82or87sl / itemJczb.pbqkSl) * 100).toFixed(2) + "%";
          } else {
            if (!itemJczb.pbqkZb) {
              itemJczb.pbqkZb = "0.0%";
            }
          }

          // 监测指标2024年配备目标
          if (
            itemJczb.pbmbSl != "" &&
            itemJczb.pbmbSl != null &&
            this.reg.test(itemJczb.pbmbSl) &&
            this.reg.test(itemJczb.pbmb83or88sl) &&
            itemJczb.pbmb83or88sl != "" &&
            itemJczb.pbmb83or88sl != null &&
            itemJczb.pbmbSl != 0
          ) {
            itemJczb.pbmbZb =
              ((itemJczb.pbmb83or88sl / itemJczb.pbmbSl) * 100).toFixed(2) + "%";
          } else {
            if (!itemJczb.pbmbZb) {
              itemJczb.pbmbZb = "0.0%";
            }
          }
        })
      },
      deep: true,
    },
  },
  methods: {
    async initShow(task, role, shztGHB, type) {
      this.task = task;
      this.btType = type;
      this.taskId = task.id;
      this.role = role;
      this.shztGHB = shztGHB;
      this.visible = true;
      this.msgData = {};
      this.excelData.excelFileName = "";
      this.excelData.excelFile = "";
      this.pbtsjhData = [];
      this.listJczb = [];
      const params = {
        taskId: task.id,
        type: "2",
      };
      this.loading = true;
      getList2024(params).then((data) => {
        console.log(data.resultdata, "data4");
        if (data.type) {
          if (data.resultdata.bt) {
            this.msgData = data.resultdata.bt;
            this.shztBegin = data.resultdata.bt.shztBegin;
          }
          if (data.resultdata.excelList) {
            this.excelData.excelFile = data.resultdata.excelList[0].excelFile;
            this.excelData.excelFileName =
              data.resultdata.excelList[0].excelFileName;
          }
          if (data.resultdata.list) {
            this.pbtsjhData = data.resultdata.list;
          }
          if(data.resultdata.listJczb){
            this.listJczb = data.resultdata.listJczb;
          }
          if (data.resultdata.tsjhList) {
            this.tsqksmData = data.resultdata.tsjhList;
          }
          this.loading = false;
        } else {
          this.$message.error(data.message);
        }
        if (this.shztGHB == "1" || this.shztBegin == "1") {
          this.flag = true;
        } else {
          var jgid = JSON.parse(sessionStorage.getItem(`userInfo`)).organizeId;
          if (jgid !== task.dwBianma) {
            if (
              role == "系统管理员" ||
              role.indexOf("干部一处") > -1 ||
              role.indexOf("干部二处") > -1 ||
              role.indexOf("干部三处") > -1 ||
              role.indexOf("干部四处") > -1 ||
              role.indexOf("干部五处") > -1
            ) {
              this.flag = true;
            } else {
              this.flag = false;
            }
          } else {
            this.flag = false;
          }
        }
      });
    },

    //保存
    save(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$confirm("是否保存?", "操作提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.msgData.taskId = this.taskId;
              this.msgData.sjd = "begin";
              this.pbtsjhData.forEach((item) => {
                item.taskId = this.taskId;
              });
              this.listJczb.forEach((item)=>{
                item.taskId = this.taskId;
                item.sjd ="begin"
              })
              const params = {
                bt: this.msgData,
                excelData: this.excelData,
                data: this.pbtsjhData,
                type: "2",
                tsqk: this.tsqksmData,
                listJczb:this.listJczb[0],
                userInfo: JSON.parse(sessionStorage.getItem(`userInfo`)),
              };
              this.loading = true;
              save2024(params).then((data) => {
                if (data.result) {
                  this.loading = false;
                  this.$message.success("保存成功!");
                  this.visible = false;
                } else {
                  this.loading = false;
                  this.$message.error(data.message);
                }
              });
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消保存!",
              });
            });
        }
      });
    },

    //审核
    auditTable() {
      this.$confirm("是否审核通过?", "操作提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const params = {
            id: this.msgData.id,
            task: this.task,
            type: "2",
          };
          this.loading = true;
          auditTable(params)
            .then((data) => {
              console.log(data, "data");
              if (data.result) {
                this.loading = false;
                this.$message.success("审核通过!");
                this.visible = false;
              } else {
                this.loading = false;
                this.$message.error(data.message);
              }
            })
            .catch((res) => {
              this.$message.error(res);
              this.loading = false;
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消审核!",
          });
        });
    },
    //附件上传函数
    fileUpload(response, file, fileList) {
      this.tsqksmData[1].tsqkFile.push(response.url);
      this.tsqksmData[1].tsqkFileName.push(file.name);
    },
    //表格扫描附件上传函数
    excelFileUpload(response, file, fileList) {
      this.excelData.excelFile = response.url;
      this.excelData.excelFileName = file.name;
    },
    //文件格式约束
    beforeAvatarUpload(file) {
      console.log(file, "beforeFile");
      const isPDF =
        file.name.substring(file.name.lastIndexOf(".") + 1) === "pdf";
      const fileSize = file.size / 1024;
      if (fileSize > 2 * 1024) {
        this.$message.error("上传附件材料不能大于2M!");
        return false;
      }
      if (!isPDF) {
        this.$message.error("上传的附件材料后缀只能是.pdf的文件格式!");
      }
      return isPDF;
    },
    //文件预览
    showFile(fileurl) {
      this.$nextTick(() => {
        this.$refs.dialogarchiveFile.initShow(fileurl);
      });
    },
    delFileByTsqk(sort) {
      this.$confirm("是否删除该附件?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.tsqksmData[1].tsqkFile.splice(sort, 1);
          this.tsqksmData[1].tsqkFileName.splice(sort, 1);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //下载
    downZip() {
      const month = new Date().getMonth() + 1;
      const params = {
        taskId: this.taskId,
        type: 2,
        fileName:
          this.msgData.dw +
          "年初制定(" +
          new Date().getFullYear() +
          "年" +
          month +
          "月).zip",
      };
      this.$confirm("是否下载?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.pageLoading = true;
        downLsqk2024(params).then((result) => {
          this.pageLoading = false;
          // this.$alert('成功')
        });
      });
    },
  },
};
</script>
    
    <style scoped>
.myTable {
  width: 100%;
  border-top: 1px solid #dcdfe6;
  border-right: 1px solid #dcdfe6;
  border-spacing: 0;
  /*去掉单元格间隙*/
}
.myTable tbody {
  width: 100%;
}
.myTable .borderNone {
  border-left: none;
}
.myTable > thead > tr {
  background-color: #f5f7fa;
}
.myTable td {
  /* word-wrap: break-word; */
  font-size: 16px;
  text-align: center;
  padding: 5px 10px;
  border-bottom: 1px solid #dcdfe6;
  border-left: 1px solid #dcdfe6;
}
>>> .el-input.is-disabled .el-input__inner {
  color: #606266;
}
/*调整表格文字*/
>>> .vxe-header--column .vxe-cell--title {
  font-size: 14px;
  font-weight: normal;
  color: #000;
}
>>> .vxe-header--row {
  background: #fff;
}
</style>
    